<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户登陆</title>
<script
	src="https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superlanding/js/lib/jquery_d88366fd.js"></script>
<script type="text/javascript">
	$(document).ready(
			function() {
				//将一个表单的数据返回成JSON对象  
				$.fn.serializeObject = function() {
					var o = {};
					var a = this.serializeArray();
					$.each(a, function() {
						if (o[this.name]) {
							if (!o[this.name].push) {
								o[this.name] = [ o[this.name] ];
							}
							o[this.name].push(this.value || '');
						} else {
							o[this.name] = this.value || '';
						}
					});
					return o;
				};

				$("#submit").click(
						function() {
							var jsonuserinfo = JSON.stringify($('#loginForm')
									.serializeObject());
							/*jsonuserinfo = "{\"userName\":\"111\",\"password\":\"111\",\"age\":111}";*/
							alert(jsonuserinfo);
							$.ajax({
								type : 'POST',
								contentType : 'application/json',
								url : '/RestaurantServer/user/doLogin',
								data : jsonuserinfo,
								dataType : 'json',
								success : function(data) {
									alert("登陆成功");
								},
								error : function(data) {
									alert("error")
								}
							});
						});
			});
</script>
</head>
<body>
	<form id="loginForm">
		用户名：<input type="text" value="" name="userName" /><br /> 
		密码:<input type="password" value="" name="userPassword" /><br /> 
		<input type="button" id="submit" value="登陆" />
	</form>
	<form id="loginForm2" action="/RestaurantServer/user/doLogin2" method="post" 
		  enctype="application/x-www-form-urlencoded">
		用户名：<input type="text" value="" name="userName" /><br /> 
		密码:<input type="password" value="" name="userPassword" /><br /> 
		<input type="submit"  value="登陆" />
	</form>
	<form id="loginForm3" action="/RestaurantServer/user/doLogin3" method="get" 
		  enctype="application/x-www-form-urlencoded">
		用户名：<input type="text" value="" name="userName" /><br /> 
		密码:<input type="password" value="" name="userPassword" /><br /> 
		<input type="submit"  value="登陆" />
	</form>
</body>
</html>